package com.likersai.funa.util;

import com.likersai.funa.pojo.dto.param.PageParam;
import com.likersai.funa.pojo.dto.req.PageReq;
import com.likersai.funa.pojo.dto.req.ParamAble;
import com.likersai.funa.pojo.vo.model.Page;
import org.springframework.beans.BeanUtils;

import java.util.List;

/**
 * 分页工具类
 *
 * @author sun.ye
 * @since 2021-07-19 21:56
 */
public class PageUtils {

    private PageUtils() {
    }

    public static void setParamFromReq(PageReq pageReq, PageParam pageParam){
        if (pageParam == null) {
            pageParam = new PageParam();
        }
        pageParam.setPage(pageReq);
    }

    public static<T> Page<T> getPage(List<T> rows, int recordsCount,PageReq pageReq){
        Page<T> page = new Page<>();
        page.setRows(rows);
        page.setPageNum(pageReq.getNum());
        page.setRecordsCount(recordsCount);
        page.setPageCount(recordsCount);
        return page;
    }

}
